ARP : ARP table management

更新时间:
2024-05-15
下载文档

ARP : ARP table management

This module provides ARP conversion table operation.

User can use the following code to import the arp module.

var arp = require('router/arp');

Support

The following shows arp module APIs available for each permissions.

 User ModePrivilege Mode
arp.add 
arp.delete 
arp.request 
arp.get

ARP Object

arp.add(ifname, ipaddr, mac[, static[, strict]])

  • ifname {String} Ethernet network interface name.
  • ipaddr {String} IP address.
  • mac {String} MAC address in the format: 'x:x:x:x:x:x'
  • static {Boolean} Whether to add as a permanent static transformation. default: true.
  • strict {Boolean} Whether to bind the unique IP address of this MAC address, valid when static is true. default: false.
  • Returns: {Boolean} Whether the operation was successful.

Add an ARP translation entry manually.

Example

arp.add('en1', '192.168.1.2', '00:22:33:44:55:66');

arp.delete(ipaddr[, ifname[, force]])

  • ipaddr {String} Need to delete IP address mapping ARP relationship.
  • ifname {String} Ethernet network interface name. default: check all ethernet interface.
  • force {Boolean} Whether to force deletion of dynamic ARP records. default: false
  • Returns: {Boolean} Whether the operation was successful.

Delete the ARP mapping of the specified IP address.

Example

arp.delete('192.168.1.2');
arp.delete('0.0.0.0'); // Delete all ARP records.
arp.delete('0.0.0.0', 'en1'); // Delete 'en1' network interface all ARP records.

arp.request(ifname, ipaddr)

  • ifname {String} Ethernet network interface name.
  • ipaddr {String | Array} The requested IP address.

Send an ARP query request to the specified IP address.

Example

arp.request('en1', '192.168.1.2');
arp.request('en1', ['192.168.1.2', '192.168.1.3']);

arp.get([ifname])

  • ifname {String | Array} Ethernet network interface name. default: get all ethernet interface.
  • Returns: {Array} Obtained ARP mapping array.

Get ARP mapping table. If no network interface is specified, get all ARP mappings.

Each array member is an object, this object contains the following properties:

  • ifname {String} This mapping network interface.
  • ipaddr {String} This mapping IP address.
  • mac {String} This mapping MAC address.
  • static {Boolean} Whether this mapping is static.
  • strict {Boolean} Whether to bind the unique IP address of this MAC address.

Example

var arps = arp.get(); // All
var arps = arp.get('en1'); // Interface en1
var arps = arp.get(['en1', 'en2']); // Interface en1 en2
for (var i = 0; i < arps.length, i++) {
  console.log(arps[i].ipaddr);
}
文档内容是否对您有所帮助?
有帮助
没帮助